package com.lzk.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lzk.common.CustomerException;
import com.lzk.common.R;
import com.lzk.dto.SetmealDto;
import com.lzk.pojo.Setmeal;
import com.lzk.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/setmeal")
public class SetmealController {
    @Resource
    private SetmealService setmealService;

    @GetMapping("/page")
    public R<Page<SetmealDto>> setmealPage(int page, int pageSize, String name) {
        return setmealService.setmealPage(page,pageSize,name);
    }
    @PostMapping
    public R<String> saveSetMeal(@RequestBody SetmealDto setmealDto){
        return setmealService.saveSetMeal(setmealDto);
    }
    @GetMapping("/{id}")
    public R<SetmealDto> showSetmealById(@PathVariable Long id){
        return setmealService.showSetmealById(id);
    }
    @PutMapping
    public R<String> updateWithDishes(@RequestBody SetmealDto setmealDto){
        return setmealService.updateWithDishes(setmealDto);
    }
    @PostMapping("/status/{status}")
    public R<String> stopSaleByIds(@PathVariable int status, @RequestParam List<Long>ids){
        return setmealService.stopSaleByIds(status,ids);
    }
    @DeleteMapping
    public R<String> delete(@RequestParam List<Long> ids) throws CustomerException {
        return setmealService.delete(ids);
    }
    @GetMapping("/list")
    public R<List<Setmeal>> listAll(Setmeal setmeal){
        return setmealService.listAll(setmeal);
    }
}
